home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
426-450
/
disk_429
/
uedit-stuff
/
ctl-click
< prev
next >
Wrap
Text File
|
1992-05-06
|
19KB
|
436 lines
PAUL'S NEW IMPROVED CONTROL-CLICK COMMANDS
These here are an improved version of the Uedit commands used for listing
directories and click-loading files. The improvements are:
Directory listings are faster because they are produced with my high
speed program Dr instead of regular Dir. See below for info about Dr.
A regular Dir version is also here.
You can drag the mouse with the control key held down to cover file or
directory names that have spaces in them.
The alt-z command is better behaved. If you don't type anything it lists
the current directory instead of the click-loading directory or "/". To
list the click-loading dir use ctl-click-whitespace F2.
There's a new command lAmiga-z which is like alt-z except that you
specify a file pattern in the directory to be listed, e.g. "U:Con#?"
Alt-z and ctl-click-whitespace-followed-by-F2 now use the same routine to
do the actual directory listing, so they no longer do the same thing two
different ways. This makes the code smaller.
When the buf38 split window is showing (with the prompt F1=Edit, F2=List,
etc) you can scroll the split vertically with the up and down arrow keys.
By default it opens scrolled to show the hilite region if any.
The version that uses Dr is I guess intended for the Extras disk. I am
including (commented out) a version that uses plain old Dir. This version
could very well (in my opinion) be the new standard vanilla control-click
command. Except that it doesn't use switch/case, to keep it compileable by
Uedit 2.4 users if it gets relegated to Extras.
If you want to use Dir, beware: Dir has a bug which will make it useless
when Uedit is a workbench process and there is no disk in the boot drive. Dr
has no such bug. (Though you do have to specify the current directory by
name instead of just hitting return, if Uedit is a workbench process, because
Uedit cannot pass its current directory to programs it executes unless it is
a CLI process.) Dr, by the way, is just as "pure" as Dir is.
Notes about control-clicking with dragging: the drag assumes you meant to
bracket all words which are wholly or partially between the two end points of
the drag. Click in the middle of either the first or the last word, and drag
to the middle of the word at the opposite end. Stay on the same line if you
want useful results. "Word" in this context means text bounded by whitespace.
It decides whether the click is in whitespace or on text when the button is
released, not when pressed. If you click in whitespace and release on text,
it will ignore the whitespace between the click and the nearest word (before
or after, depending on whether you dragged the mouse leftward or rightward).
If you click on text and release on whitespace, it opens the buf38 split
window. There is a comment in virtual-buttonDown showing how you can make it
decide on the click rather than on the release whether it is on whitespace or
text.
You can clear the click-loading directory (so that you can click-load names
of files in the current directory) by ctl-clicking on whitespace when the
buf38 split is open. There should be a space at the beginning of the first
line of buf38, because both this version and the original version have a
problem otherwise: they will hilite the first word in buf38 if you ctl-click
on whitespace in a different window split.
About scrolling the split window: It begins with the top line visible,
unless there is a hilite region below the bottom end, in which case it
scrolls so that the hilite region is visible. You can then scroll it
manually using the up and down arrow keys. But there is a little flaky
problem here. If you keep pressing downArrow when the last line is at the
top, it scrolls rightward (the text moves left) until no text is visible. If
you replace the two refreshDisplay's in virtual-buttonUp's cases for macroNum
= normal-downArrow and normal-upArrow with updateDisplay's instead, it
doesn't scroll sideways but may fail to show the cursor and the hilite
region if they're scrolled out of view and then back.
ABOUT DR: Dr is a full featured CLI directory listing command which has been
optimized for speed to within an inch of my life. It is plenty faster than
some other "fast" listing programs. It is pure and can be made resident.
It is intended to replace both Dir and List. (And other programs as well: du
and rls.) If you want the complete documentation and source code for Dr,
they'll probably be on a Fish disk some time in early 1991, if the doc file
isn't included with this file. For simple help on how to use Dr, just give
the command "Dr ?". The most important thing that the usage summary doesn't
tell you is that by default, .info files are left out of the listing.
Instead, when the output is to a console window, files that have .info files
associated with them get their names written in orange (or whatever color the
window's text cursor is). When the output is sent to Uedit, there is no such
marking. You can make .info files appear by changing the command in virtual-
d from "Dr " to "Dr -i ", but I don't know why you'd want to.
This stuff is by Paul Kienitz
6430 San Pablo ave.
Oakland, CA 94608
USA
and is in the public domain.
============================================================================
Here are the actual functions:
Mark region clicked with mouse
<virtual-buttonDown:
moveCursor(curFile,mouseLoc)
.. change mouseLoc to locA ^^^ to make it decide on the click not the release
if (eqNum(curFile,38)) equateLoc(buf38,eHilite,sHilite)
if (is(curFile,eFile)) returnFalse
if (is(curFile,whiteSpace)) returnFalse
if (gtLoc(curfile, mouseLoc, locA)) {
equateLoc(curFile, sInvert, locA)
equateLoc(curFile, eInvert, mouseLoc)
} else {
equateLoc(curFile, sInvert, mouseLoc)
equateLoc(curFile, eInvert, locA)
}
moveCursor(curFile, sInvert)
while (not is(curFile,whiteSpace)) { .. find start non-white
moveCursor(curFile,sChar)
if (is(curFile,sFile)) goto label(1)
}
label(1)
while (is(curFile,whiteSpace)) moveCursor(curFile,eChar)
equateLoc(curFile,sInvert,atCursor) .. sinvert = start non-white
moveCursor(curFile, eInvert)
while (not is(curFile,whiteSpace)) { .. find end non-white
moveCursor(curFile,eChar)
if (is(curFile,eFile)) goto label(2)
}
label(2)
while (is(curFile,whiteSpace)) moveCursor(curFile,sChar)
moveCursor(curFile, eChar)
equateLoc(curFile,eInvert,atCursor) .. einvert = end non-white
if (eqNum(curFile,38)) { .. in directory buffer 38
equateLoc(curFile,sHilite,sInvert)
equateLoc(curFile,eHilite,eInvert)
equateLoc(curFile,sInvert,eInvert)
moveCursor(curFile,sHilite)
}
refreshDisplay
>
Load File or select Directory that is CTRL-clicked
<ctl-buttonDown:
equateNum(n7,curFile)
equateLoc(curFile, locA, mouseLoc)
if (mouseDown) while (not inputWaiting)
trackMouse
if (not runKey(virtual-buttonDown)) {
runKey(virtual-buttonUp)
return
}
if (not eqNum(curFile,38)) {
if (geLoc(curFile,sInvert,eInvert)) return .. no rgn
moveCursor(curFile,sChar)
if (not is(curFile,"/")) if (not is(curFile,":")) {
freeBuf(buf43) .. leave in current filename buf
moveCursor(curFile,sInvert)
while (not eqLoc(curFile,atCursor,eInvert)) {
if (is(curFile,":")) goto label(99)
moveCursor(curFile,eChar)
}
insertRgn(buf43,sFile,buf38,hilite)
label(99)
insertRgn(buf43,eFile,curFile,invert)
loadFile(buf43)
.. these two lines are a feature I like in my own version of this and alt-f1:
.. if (not eqNum(curFile, buf0))
.. if (isEmpty(buf0)) freeBuf(buf0) .. eliminate excess NoNames
return
}
moveCursor(curFile,eInvert)
freeBuf(buf53)
insertRgn(buf53,eFile,curFile,invert)
runKey(virtual-7) .. add dir to buf38
}
runKey(virtual-9) .. show dir msg
>
Handle buf38 directory traffic
<virtual-buttonUp:
runKey(virtual-8) .. load in dir defaults if not loaded
equateNum(n8,0)
if (not eqNum(curFile,38)) if (not gotoSplit(buf38)) {
if (not splitWindow(buf38,splitsize)) {
putMsg("Close a split window so I can show buf38")
return
}
equateNum(n8,1) .. had to make split window
}
vScroll(atCursor) .. bug workaround
vScroll(sFile)
updateDisplay
.. this ^^ updateDisplay does need to be here even when the updateDisplay a
.. few lines down also happens. apparently another facet of the same bug
if (gtLoc(curFile, eHilite, sHilite))
if (geLoc(curFile, sHilite, ePage)) {
vScroll(sHilite)
... vScroll(upLine) .. I like to have this here
updateDisplay
}
label(98)
equateLoc(buf38,mouseLoc,sFile)
.. if you un-comment this putmsg, comment out the following text calls:
.. putMsg(
.."Ctl-mouse=Select F1=Edit F2=List F3=Save F4=ChDir F5=CD? Arrow=scroll")
text("Ctl-click to select (hilite) a directory", 1, 0, 7, -1)
text("F1 to edit this directory buffer", 2, 0, -1, -1)
text("F2 to list the hilited dir's contents", 3, 0, -1, -1)
text("F3 to save this directory buffer to disk", 4, 0, -1, -1)
text("F4 to set Uedit's current directory to the hilited dir", 5, 0, -1, -1)
text("F5 to display Uedit's current directory", 6, 0, -1, -1)
text("Uparrow and downarrow keys to scroll the directory buffer", 7, 0, -1, -1)
getKeyVal(macroNum,inputChar)
.. use SWITCH (macronum) here, if you are using Uedit 2.5+
if (eqNum(macroNum,normal-buttonDown)) { .. done bring down window
gotoSplit(buf[n7])
if (eqNum(n8,1)) splitWindow(buf38,0) .. close it if made it
.. I prefer to make the closing of the split window unconditional
runKey(virtual-9)
return
}
if (eqNum(macroNum,normal-downArrow)) {
vScroll(downLine)
refreshDisplay
}
if (eqNum(macroNum,normal-upArrow)) {
vScroll(upLine)
refreshDisplay
}
if (eqNum(macroNum,ctl-buttonDown)) {
equateLoc(curfile, locA, mouseLoc)
if (mouseDown) while (not inputWaiting)
trackMouse
if (not runKey(virtual-buttonDown))
refreshDisplay
runKey(virtual-9)
delay(10)
}
if (eqNum(macroNum,normal-f1)) { .. edit buf38
putMsg("Press lAmiga-0 to eliminate split window.")
return
}
if (eqNum(macroNum,normal-f2)) { .. get dir list
gotoSplit(buf[n7])
if (eqNum(n8,1)) splitWindow(buf38,0) .. close it if made it
.. I prefer to close the split unconditionally
freebuf(buf50)
insertrgn(buf50, efile, buf38, hilite)
.. this virtual-d takes dir-to-scan in buf50 so L-z can give it patterns
runkey(virtual-d)
updatedisplay
return .. resume normal editing
}
if (eqNum(macroNum,normal-f3)) saveFile(buf38)
if (eqNum(macroNum,normal-f4)) { .. change dir
if (gtLoc(buf38,eHilite,sHilite)) {
freeBuf(buf54)
insertRgn(buf54,eFile,buf38,hilite)
changeDir(buf54)
goto label(0)
}
}
if (eqNum(macroNum,normal-f5)) { .. get CD
label(0)
freeBuf(buf53)
execute(buf53,"CD")
freeBuf(buf54)
insertRgn(buf54,eFile,"current directory = ",all)
insertRgn(buf54,eFile,buf53,line)
putMsg(buf54)
delay(20)
}
goto label(98)
>
Read a directory (with Dr) into a pseudo-requester click-loading buffer
<virtual-d: equatenum(n0, curfile)
if (newFile) {
equateLoc(curFile,sPage,sFile)
.. updateDisplay
freeBuf(buf54)
insertRgn(buf54,eFile,"Dr \"",all) .. " <- make em match
insertRgn(buf54,eFile,buf50,all)
moveCursor(buf54, eFile)
insertChar(buf54,"\"") .. "
setFileName(curFile, buf54)
execute(curFile,buf54)
.. These next three or four lines are strictly OPTIONAL:
.. movecursor(curfile, sfile)
.. insertchar(curfile, eline)
.. insertrgn(curfile, sfile, buf38, hilite)
.......... insertrgn(curfile, sfile, " Contents of ", all)
.. massage dir list Dr style:
getSearch(buf49)
moveCursor(curFile,sFile)
.. Include this line IF the 3 or 4 optional lines above are used:
.. moveCursor(curfile,downLine)
setSearch("/")
while (search(curFile,locA,locB,1)) {
movecursor(curfile, echar)
while (is(curfile, whitespace)) clearchar(curfile)
insertchar(curfile, eline)
moveCursor(curFile,sLine)
insertRgn(curFile,atCursor,buf38,hilite)
movecursor(curfile, eline)
}
.. do something to remove the line of dashes?
setSearch(buf49) .. restore search string
moveCursor(curFile,sFile)
flipFlag(curFile,changed)
putMsg("Ctl-click dirnames to add to buf38, filenames to load.")
} else putMsg("Can't open file buffer for directory listing")
>
HERE'S THE REGULAR DIR VERSION:
Read a directory (with Dir) into a pseudo-requester click-loading buffer
.. <virtual-d:
equatenum(n0, curfile)
if (newFile) {
equateLoc(curFile,sPage,sFile)
.. updateDisplay
freeBuf(buf54)
insertRgn(buf54,eFile,"Dir ",all)
insertRgn(buf54,eFile,buf50,all)
setFileName(curFile, buf54)
execute(curFile,buf54)
.. These next three or four lines are strictly OPTIONAL:
.. movecursor(curfile, sfile)
.. insertchar(curfile, eline)
.. insertrgn(curfile, sfile, buf38, hilite)
.......... insertrgn(curfile, sfile, " Contents of ", all)
.. massage dir list Dir style:
getSearch(buf49)
moveCursor(curFile,sFile)
.. Include this line IF the 3 or 4 optional lines above are used:
.. moveCursor(curfile,downLine)
setSearch(" (dir)")
while (search(curFile,locA,locB,1)) {
clearRgn(curfile,loc)
insertChar(curfile,"/")
moveCursor(curFile,sLine)
while (is(curfile, whitespace)) clearchar(curfile)
insertRgn(curFile,atCursor,buf38,hilite)
movecursor(curfile, eline)
}
setSearch(buf49) .. restore search string
moveCursor(curFile,sFile)
flipFlag(curFile,changed)
putMsg("Ctl-click dirnames to add to buf38, filenames to load.")
} else putMsg("Can't open file buffer for directory listing")
>
Get directory listing. (Also set dirname used in ctl-buttonDown.)
<alt-z: putMsg("Directory to list:")
freeBuf(buf53)
inputString(buf53)
freeBuf(buf50)
insertRgn(buf50, eFile, buf53, all)
if (not isEmpty(buf53)) runKey(virtual-7)
else equateLoc(buf38, eHilite, sHilite)
runKey(virtual-d) >
.. the reason we don't just go if (inputstring) is that if the user goes alt-z
and then types something and then erases it again, inputstring returns true
and a slash gets put in buf38. I have in general removed "if (inputstring..."
tests throughout most of my config.
Get a directory listing, using a pattern. (Sets ctl-click dir)
<lAmiga-z: Putmsg("Directory/pattern to list:")
freebuf(buf50)
inputstring(buf50)
movecursor(buf50, efile)
while (movecursor(buf50, schar)) {
if (is(buf50, ":") | is(buf50, "/")) {
movecursor(buf50, echar)
equateloc(buf50, ehilite, atcursor)
goto label (1)
}
}
equateloc(buf50, ehilite, sfile)
label (1)
equateloc(buf50, shilite, sfile)
freebuf(buf53)
insertrgn(buf53, sfile, buf50, hilite)
if (not isempty(buf53)) runkey(virtual-7)
else equateloc(buf38, ehilite, shilite)
runkey(virtual-d)
>
That there assumes that virtual-d is getting a dirname from buf50 instead of
the hilite region of buf38
Just for the hell of it, I'll throw these two in:
Change the current working directory
<altCtl-z: putMsg("Change current directory to:")
freeBuf(buf53)
inputString(buf53) .. if returns false go ahead anyway
if (not changeDir(buf53))
putmsg("Couldn't find that directory") >
Execute an AmigaDOS command made from last cut text and show the results
<shftCtl-z: putmsg("Enter AmigaDOS command")
freebuf(buf40)
.. If you use the standard cut&paste commands which store the last cut in
.. buf45, leave the next line in. If you use my special cut&paste commands
.. that remember the last eight cuts, comment out this next line and un-
.. comment the line after it:
insertrgn(buf40, efile, buf45, all)
.... insertrgn(buf40, efile, buf[n28], all)
inputString(buf40)
if (isempty(buf40)) returnFalse
freeBuf(buf39)
if (not execute(buf39,buf40)) returnFalse
if (not isEmpty(buf39)) {
putMsg("Result of AmigaDOS command:")
if (getFlag(buf39, changed)) flipFlag(buf39,changed)
editBuf(buf39)
vScroll(sFile)
updateDisplay
} else {
putMsg("No reply from AmigaDOS.")
freeBuf(buf39)
}
>